/**
 * \file algo-genetique.h
 * \brief les prototypes des fonctions d'algo génétique
 * \author Somayya ELMATA
 * \author Theo BRASSEUR
 * \version 0.1
 * \date 25/12/2013
 *
 * Ce fichier contient les prototypes des fonctions d'algo génétique.
 *
 */
#ifndef TSM
#define TSM 
#include "tsm.h"
#endif

#ifndef STD
#define STD
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif

typedef struct individu
{
	Path trajet;
	struct individu* next;
}Individu;

typedef Individu* Population;

//Initialisation
Population init_population(int taille, City* city, int nbrcity,City depart);
void evaluation(Population p);

//Selection 
Population* selection(Population *population, int quota, int choix_methode,int nbrcity) ;
Population* elitiste(Population *population, int quota);
Population* tournoi(Population *population, int quota);

//Croisement
void croisement(Population population, float proba);  
int croiser(Path parent1, Path parent2, int poin1, int point2);
int* indice_croisement(Path parent1, Path parent2);

//Mutation
Population mutation(Population population, float proba);
Path muter(Path individu);

//Critere nouvelle generation
int crit_new_generation(Population population, int generation, double moyenne);


//Outils gestion population
Population* supprimer_individu(Population* population, int i);
int ajouter_individu(Population* debut_population, Population nouveau);
int compare_path(Path a, Path b);
Path rand_path(City* villes, int longueur,City depart);
Population creer_individu(Path chemin);
void print_population(Population debut_population);
Path copier(Path modele);
int taille_pop(Population debut_population);
int existing(Population debut_population, Population nouveau);
long int factorielle(int n);
double get_dst_chemin(Population population, int ind);
int compare_city(City c1, City c2 );
void free_population(Population population);
double moins_bon(Population p);
Path plus_court_chemin(Population p);
